package org.budo.netty.servlet.server.handler.servlet.config;

import java.util.Collections;
import java.util.Enumeration;

import javax.servlet.FilterConfig;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;

import org.budo.netty.servlet.server.handler.servlet.registration.BudoFilterRegistration;

/**
 * @author lmw
 */
public class BudoFilterConfig implements FilterConfig {
    private FilterRegistration filterRegistration;

    public BudoFilterConfig(FilterRegistration filterRegistration) {
        this.filterRegistration = filterRegistration;
    }

    @Override
    public String getInitParameter(String name) {
        return this.filterRegistration.getInitParameter(name);
    }

    @Override
    public String getFilterName() {
        return this.filterRegistration.getName();
    }

    @Override
    public ServletContext getServletContext() {
        return ((BudoFilterRegistration) this.filterRegistration).getServletContext();
    }

    @Override
    public Enumeration<String> getInitParameterNames() {
        return Collections.enumeration(this.filterRegistration.getInitParameters().keySet());
    }

    @Override
    public String toString() {
        return super.toString() //
                + ", filterName=" + this.getFilterName() //
                + ", servletContext=" + this.getServletContext();
    }
}
